﻿using System;
using UnityEngine;
using Object = UnityEngine.Object;

public class PrefabTools {
	// === Public =====================================================================================================
	public static PrefabTools CreateInstance() {
		var instance = new PrefabTools();
		return instance;
	}

	public string GetPrefab(FieldElementType type) {
		switch (type) {
			case FieldElementType.Frame:
				return Constants.Resources.Prefabs.Elements.FRAME;
			case FieldElementType.Stone:
				return Constants.Resources.Prefabs.Elements.STONE;
			case FieldElementType.GreenApple:
				return Constants.Resources.Prefabs.Elements.GREEN_APPLE;
			case FieldElementType.RedApple:
				return Constants.Resources.Prefabs.Elements.RED_APPLE;
			default:
				throw new Exception("WTF");
		}
	}

	public string GetPrefab(FieldBodyType type) {
		switch (type) {
			case FieldBodyType.Head:
				return Constants.Resources.Prefabs.Snake.HEAD;
			case FieldBodyType.Tail:
				return Constants.Resources.Prefabs.Snake.TAIL;
			default:
				throw new Exception("WTF");
		}
	}

	public string GetPrefab(GUIPanelType type) {
		switch (type) {
			case GUIPanelType.Menu:
				return Constants.Resources.Prefabs.Gui.MENU_PANEL;
			case GUIPanelType.Option:
				return Constants.Resources.Prefabs.Gui.OPTION_PANEL;
			case GUIPanelType.Info:
				return Constants.Resources.Prefabs.Gui.INFO_PANEL;
			case GUIPanelType.LossLife:
				return Constants.Resources.Prefabs.Gui.LOSS_LIFE_PANEL;
			case GUIPanelType.GameOver:
				return Constants.Resources.Prefabs.Gui.GAME_OVER_PANEL;
			default:
				throw new Exception("WTF");
		}
	}

	public T Create<T>(string namePrefab, Vector3 position = default(Vector3), Quaternion quaternion = default(Quaternion)) where T : Object {
		return (T)Object.Instantiate(Tools.Resources.GetObjectFromResources(namePrefab), position, quaternion);
	}
}